package com.jwmp.core.util;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description TODO
 * @Version 1.0
 */
public class PageResult {
    private int  currentPage;   // 当前页码
    private int  pageSize;      // 每页显示的记录数
    private List list;          // 每页的数据
    private int  totalCount;    // 总记录书
    private int  totalPage;     // 总页数
    private int  prevPage;      // 上一页页码
    private int  nextPage;      // 下一页页码

    public PageResult(int currentPage, int pageSize) {
        this(currentPage,pageSize,new ArrayList(),0);
    }

    public PageResult(int currentPage, int pageSize, List list, int totalCount) {
        this.currentPage = currentPage;
        this.pageSize = pageSize;
        this.list = list;
        this.totalCount = totalCount;

        this.totalPage = totalCount % pageSize == 0 ? totalCount / pageSize : totalCount / pageSize + 1;
        this.prevPage = currentPage - 1 >= 1 ? currentPage - 1 : 1;
        this.nextPage = currentPage + 1 <= this.totalPage ? currentPage + 1 : this.totalPage;
    }

    public int getCurrentPage() {
        return currentPage;
    }

    public int getPageSize() {
        return pageSize;
    }

    public List getList() {
        return list;
    }

    public int getTotalCount() {
        return totalCount;
    }

    public int getTotalPage() {
        return totalPage;
    }

    public int getPrevPage() {
        return prevPage;
    }

    public int getNextPage() {
        return nextPage;
    }
}
